﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTime>
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    m_tcpserver = new QTcpServer;
    m_tcpserver->listen(QHostAddress::Any,7900);
    connect(m_tcpserver,SIGNAL(newConnection()),this,SLOT(slot_connect()));
   /* m_tcpserverBase = new QTcpServer;
    m_tcpserverBase->listen(QHostAddress::Any,7900);

    connect(m_tcpserverBase,SIGNAL(newConnection()),this,SLOT([=]{
        m_tcpsocketBase = m_tcpserverBase->nextPendingConnection();
        connect(m_tcpsocketBase,SIGNAL(readyRead()),this,SLOT(slot_readyRead()));
    }));*/
   // m_modbusClient.connect("127.0.0.1",502);
  //  m_modbusClient.connect("192.168.6.6",502);
  //  m_modbusClient.initReadRegister16(4340,4);
   // m_modbusClient.initReadRegister16(4120,4);//60

}

MainWindow::~MainWindow()
{
    delete ui;
}

void elapsed_QTime(int ms)
{
    QTime t;
    t.start();
    //    while(t.elapsed() < ms);//no response
    while(t.elapsed() < ms)//response
    {
        QCoreApplication::processEvents();
    }
}

void MainWindow::slot_connect()
{
    m_tcpsocket = m_tcpserver->nextPendingConnection();
    connect(m_tcpsocket,SIGNAL(readyRead()),this,SLOT(slot_readyRead()));
    qDebug()<<"connect";
    //ui->pushButton_2->setText("show");

}

void MainWindow::slot_start()
{

}

void MainWindow::on_pushButton_clicked()
{
   // m_modbusClient.readFloat32(4340,x);

   // m_modbusClient.readFloat32(4342,y);
   /*  QVector<float>v;
    v<<2;
    m_modbusClient.writeRegisterFloatVector(4122,v,v.size());
*/
    if(tag == 1)
    {
       QCursor::setPos(509, 206);
       QPoint globalPos = QCursor::pos();
       elapsed_QTime(500);
       mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
       mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
       elapsed_QTime(500);

       QCursor::setPos(1575, 137);
       globalPos = QCursor::pos();
       elapsed_QTime(500);
       mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
       elapsed_QTime(500);
       mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
       elapsed_QTime(500);

       QCursor::setPos(1583, 199);
       globalPos = QCursor::pos();
       mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
       mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
       elapsed_QTime(500);

       QCursor::setPos(1583, 374);
       globalPos = QCursor::pos();
       mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
       mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
       elapsed_QTime(500);

       QCursor::setPos(1550, 402);
       globalPos = QCursor::pos();
       mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
       mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
       elapsed_QTime(500);

        QCursor::setPos(363,577);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(738, 270);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(652, 312);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);


        QCursor::setPos(515, 272);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos((x-lenth)*0.174+481,(y-width)*0.173+293);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        QCursor::setPos((x+lenth)*0.174+481,(y+width)*0.173+293);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);

///////
        QCursor::setPos(1158, 485);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1144, 550);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1154, 530);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);


        for(int i=0;i<5;i++)
        {
            keybd_event(VK_BACK, 0, 0, 0);
            keybd_event(VK_BACK, 0, KEYEVENTF_KEYUP, 0);
        }
        QString s = "2.5";
        for (const QChar &ch : s)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }
        //


        QCursor::setPos(746,225);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(2000);

        QString dateText = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
        for (const QChar &ch : dateText)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }

        QCursor::setPos(864,644);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(5000);

        QCursor::setPos(801,488);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1163,679);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(896,133);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(164,288);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(738, 270);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(776,311);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        for (const QChar &ch : dateText)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }

        QCursor::setPos(1066,697);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(2000);

        QCursor::setPos(749,475);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);


        QCursor::setPos(995,136);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(946,620);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1575, 137);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1583, 199);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1571, 173);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(253,270);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(738, 270);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(776,311);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        for (const QChar &ch : dateText)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }

        QCursor::setPos(1066,697);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(2000);

        QCursor::setPos(320,135);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
    }
    else if(tag == 3)
    {
        QCursor::setPos(1575, 137);
        QPoint globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1583, 199);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1583, 374);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1535, 375);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(363,577);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(738, 270);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(652, 312);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);


        QCursor::setPos(515, 272);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos((x2-lenth)*0.174+481,(y2-width)*0.173+293);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        QCursor::setPos((x2+lenth)*0.174+481,(y2+width)*0.173+293);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);

        QCursor::setPos(1107, 477);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1107, 497);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1116, 503);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        for(int i=0;i<5;i++)
        {
            keybd_event(VK_BACK, 0, 0, 0);
            keybd_event(VK_BACK, 0, KEYEVENTF_KEYUP, 0);
        }
        QString s = "3";
        for (const QChar &ch : s)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }

        QCursor::setPos(1116, 534);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);


        for(int i=0;i<5;i++)
        {
            keybd_event(VK_BACK, 0, 0, 0);
            keybd_event(VK_BACK, 0, KEYEVENTF_KEYUP, 0);
        }
        s = "1";
        for (const QChar &ch : s)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }
        ///////
        QCursor::setPos(1158, 485);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);



        QCursor::setPos(746,225);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(2000);

        QString dateText = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
        for (const QChar &ch : dateText)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }

        QCursor::setPos(864,644);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(5000);

        QCursor::setPos(749,475);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(801,488);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1169,677);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1575, 137);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1583, 374);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1583, 199);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1526, 203);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(518,299);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(738, 270);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(776,311);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        for (const QChar &ch : dateText)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }

        QCursor::setPos(1066,697);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(2000);

        QCursor::setPos(320,135);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(946,620);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
    }
    else if(tag == 2)
    {
        elapsed_QTime(5000);
        QCursor::setPos(1575, 137);
        QPoint globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1583, 199);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1583, 374);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1535, 375);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(363,577);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(738, 270);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(652, 312);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);


        QCursor::setPos(515, 272);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos((x-lenth)*0.174+481,(y-width)*0.173+293);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        QCursor::setPos((x+lenth)*0.174+481,(y+width)*0.173+293);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);

        x2 = x;
        y2 = y;


        QCursor::setPos(1107, 477);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1107, 497);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1116, 503);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        for(int i=0;i<5;i++)
        {
            keybd_event(VK_BACK, 0, 0, 0);
            keybd_event(VK_BACK, 0, KEYEVENTF_KEYUP, 0);
        }
        QString s = "3";
        for (const QChar &ch : s)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }

        QCursor::setPos(1116, 534);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);


        for(int i=0;i<5;i++)
        {
            keybd_event(VK_BACK, 0, 0, 0);
            keybd_event(VK_BACK, 0, KEYEVENTF_KEYUP, 0);
        }
        s = "1";
        for (const QChar &ch : s)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }


        ///////
        QCursor::setPos(1158, 485);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);



        QCursor::setPos(746,225);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(2000);

        QString dateText = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
        for (const QChar &ch : dateText)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }

        QCursor::setPos(864,644);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(5000);

        QCursor::setPos(749,475);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(789,487);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1169,677);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1575, 137);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1583, 374);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        //mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1583, 199);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1506, 231);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(519,302);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(738, 270);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(776,311);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        for (const QChar &ch : dateText)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }

        QCursor::setPos(1066,697);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(2000);

        QCursor::setPos(320,135);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(946,620);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
    }
    else
    {
        QCursor::setPos(1575, 137);
        QPoint globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1535, 413);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(363,577);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(738, 270);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(652, 312);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);


        QCursor::setPos(515, 272);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos((968-lenth)*0.242+457,(732-width)*0.243+293);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        QCursor::setPos((968+lenth)*0.242+457,(732+width)*0.243+293);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);



        QCursor::setPos(1107, 477);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1107, 497);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1116, 503);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        for(int i=0;i<5;i++)
        {
            keybd_event(VK_BACK, 0, 0, 0);
            keybd_event(VK_BACK, 0, KEYEVENTF_KEYUP, 0);
        }
        QString s = "3";
        for (const QChar &ch : s)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }

        QCursor::setPos(1116, 534);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);


        for(int i=0;i<5;i++)
        {
            keybd_event(VK_BACK, 0, 0, 0);
            keybd_event(VK_BACK, 0, KEYEVENTF_KEYUP, 0);
        }
        s = "3";
        for (const QChar &ch : s)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }
        ///////
        QCursor::setPos(1158, 485);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);


        QCursor::setPos(746,225);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(2000);

        QString dateText = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
        for (const QChar &ch : dateText)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }

        QCursor::setPos(864,644);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(5000);

        QCursor::setPos(749,475);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(801,488);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1169,677);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1575, 137);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1583, 199);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1583, 374);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(1510, 341);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(161,273);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(738, 270);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        QCursor::setPos(776,311);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(500);

        for (const QChar &ch : dateText)
        {
            // 将字符转换为大写并获取虚拟键码
            WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
            sendKeyPress(keyCode);
            sendKeyRelease(keyCode);
        }

        QCursor::setPos(1066,697);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(2000);

        QCursor::setPos(944,620);
        globalPos = QCursor::pos();
        mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
        mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
        elapsed_QTime(2000);

        tag = 0;
    }
    m_tcpsocket->write("end");

}

void MainWindow::sendKeyPress(WORD keyCode)
{
    INPUT input = {0};
    input.type = INPUT_KEYBOARD;
    input.ki.wVk = keyCode; // 虚拟键码
    SendInput(1, &input, sizeof(INPUT));
}

void MainWindow::sendKeyRelease(WORD keyCode)
{
    INPUT input = {0};
    input.type = INPUT_KEYBOARD;
    input.ki.wVk = keyCode;
    input.ki.dwFlags = KEYEVENTF_KEYUP; // 释放键
    SendInput(1, &input, sizeof(INPUT));
}
void MainWindow::on_pushButton_2_clicked()
{
    //1算出缩放比 照片在屏幕上的像素/照片像素
    //2找到照片在屏幕上的起始像素点
    QCursor::setPos((2755.31-61*6)*0.1469+719,(1826.89-61*6)*0.1466+558);
    QPoint globalPos = QCursor::pos();
    mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
    mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);
    QCursor::setPos((2755.31+61*6)*0.1469+719,(1826.89+61*6)*0.1466+558);
    globalPos = QCursor::pos();
    mouse_event(MOUSEEVENTF_LEFTDOWN, globalPos.x(),globalPos.y() , 0, 0);
    mouse_event(MOUSEEVENTF_LEFTUP, globalPos.x(), globalPos.y(), 0, 0);




    return;
    ui->lineEdit->setFocus();
    elapsed_QTime(500);
    QString s = "abc";
    for (const QChar &ch : s)
    {
        // 将字符转换为大写并获取虚拟键码
        WORD keyCode = VkKeyScanEx(ch.toLatin1(), GetKeyboardLayout(0)) & 0xFF;
        sendKeyPress(keyCode);
        sendKeyRelease(keyCode);
    }
}

void MainWindow::slot_readyRead()
{
    QByteArray msg = m_tcpsocket->readAll();
    if (QString::fromLocal8Bit(msg).contains("start"))
    {
        tag++;
        on_pushButton_clicked();
        return;
    }
    if (QString::fromLocal8Bit(msg).contains("stop"))
    {
        tag = 0;
        //on_pushButton_clicked();
        return;
    }
    if (QString::fromLocal8Bit(msg).contains("pause"))
    {
        tag--;
        //on_pushButton_clicked();
        return;
    }
   /* else if(QString::fromLocal8Bit(msg).contains("ID"))
    {
        QStringList list = QString::fromLocal8Bit(msg).split("ID");
    }*/
    QStringList list = QString::fromLocal8Bit(msg).split(",");
    x = list[0].toFloat();
    y = list[1].toFloat();
    lenth = list[2].toInt()/2;
    width = list[3].toInt()/2;


}
